package com.xia.ndk_audio;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.widget.TextView;

import java.io.File;

public class MainActivity extends AppCompatActivity {
    // 播放原始数据 ffplay -ar 44100 -channels 2 -f s16le -i output.pcm
    // Used to load the 'native-lib' library on application startup.
    static {
        System.loadLibrary("my-player");
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        File inputFile = new File(Environment.getExternalStorageDirectory(), "input.mp3");
        Log.d("MainActivity", "onCreate: size ========"+inputFile.length()+"---------"+inputFile.getAbsolutePath());
        File outputFile = new File(Environment.getExternalStorageDirectory(), "output.pcm");
        playMusic(inputFile.getAbsolutePath(), outputFile.getAbsolutePath());

    }

    /**
     * A native method that is implemented by the 'native-lib' native library,
     * which is packaged with this application.
     */
    public native String stringFromJNI();

    /**
     * @param input  mp4  mp3  avi...
     * @param output 原始数据PCM
     */
    public native void playMusic(String input, String output);
}
